 <%--
 *  File:   BusinessInfoBuyStockData.jsp
 *  Desc:	the Lend slip summary page
 *
 *  Date		  Author		   Changes
 *  2011-6-20	  JackYin		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "R30030";
  String strTableName = "v_zylbusinessalesinfostock";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>
<%@ include file="/inc/Security.inc" %>

<html>
<head>
<title>BusinessInfoBuyStockData.jsp</title>
<PageFlow:CheckPageFlow pageName="p_zylbusinessareainfobuystock"/>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>
<%@ include file="/rpt/ReportURL.inc" %>

<%
HashMap userinfo = (HashMap)session.getAttribute("userinfo");
Integer  issalesman = (Integer) userinfo.get("issalesman");
String  username = (String) userinfo.get("employeename");
String flag = (String)pageContext.getAttribute("flag");
java.util.Calendar cal = java.util.Calendar.getInstance();   
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "BusinessInfoBuyStockData.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function clickRow(obj,idx)
{
  var cform = document.cform;
  cform.radiorow[idx].checked=true;
  //cform.orgid.value = eval('obj.all.orgid'+idx).value;
  //cform.productid.value = eval('obj.all.productid'+idx).value;
 cform.year.value = eval('obj.all.year'+idx).value;
  cform.month.value = eval('obj.all.month'+idx).value;
}


 
 function SetSalesMan(id,code,name){
	cform.userids.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

 
function popRep() {
	var regionid=cform.regionid.value;
	var proviceofficecode = document.cform.proviceofficelist.value;
	var businessareacode = document.cform.businessarealist.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid+"&proviceofficecode="+proviceofficecode+"&businessareacode="+businessareacode;
  
	popwindow = window.open(url, "newwindow", status);
  }
  
  function page_getpriviceoffice(){
	var objdeptcode=eval("cform.regionid");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , objdeptcode.value , "Integer");
	datahandler.getResultFromVector("resultproviceoffice","proviceofficename","proviceofficecode","document.cform.proviceofficelist");
	datahandler.add_job("j_zylbusinessareainfobuystock");
	datahandler.runDataHandler();
  }
  
  function page_getbusinessarea(){
	var objdeptcode=eval("cform.proviceofficelist");
	var regionid = document.cform.regionid.value;
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , regionid , "Integer");
	datahandler.add_params("proviceofficelist" , objdeptcode.value , "String");
	datahandler.getResultFromVector("resultbusinessarea","businessareaname","businessareacode","document.cform.businessarealist");
	datahandler.add_job("j_zylbusinessareainfobuystock");
	datahandler.runDataHandler();
 }

function page_excel(){
	v_year1=document.cform.years1.value;
	v_year2=document.cform.years2.value;
	v_month1=document.cform.months1.value;
	v_month2=document.cform.months2.value;
	str1="TO_DATE(b.YEAR || '-' || b.MONTH,'yyyy-mm')>=TO_DATE(";
	str2=v_year1;
	str3="|| '-' ||";
	str4=v_month1;
	str5=" ,'yyyy-mm')";
	startdate=str1+str2+str3+str4+str5;
	
	str_1="TO_DATE(b.YEAR || '-' || b.MONTH,'yyyy-mm')<=TO_DATE(";
	str_2=v_year2;
	str_3="|| '-' ||";
	str_4=v_month2;
	str_5=" ,'yyyy-mm')";
	enddate=str_1+str_2+str_3+str_4+str_5;

	var objdeptcode=eval("cform.regionid");
  	var ss=objdeptcode.selectedIndex;
  	var AREA1NAME=objdeptcode.options[ss].text;
  	if(AREA1NAME=="ALL"){
  		AREA1NAME="";
  	}
  	
  	var objdeptcode1=eval("cform.proviceofficelist");
  	var ss1=objdeptcode1.selectedIndex;
  	var AREA2NAME=objdeptcode1.options[ss1].text;
  	if(AREA2NAME=="----------" || AREA2NAME=="-------"){
  		AREA2NAME="";
  	}
  	
  	var objdeptcode2=eval("cform.businessarealist");
  	var ss2=objdeptcode2.selectedIndex;
  	var AREA3NAME=objdeptcode2.options[ss2].text;
  	if(AREA3NAME=="----------" || AREA3NAME=="-------"){
  		AREA3NAME="";
  	}
	SALESREPNAME=document.cform.employeename.value;
	if((v_year1==null || v_year1=="") && (v_year2==null || v_year2=="")){
		window.open("<%= reportURL %>/servlet/ExcecuteReport/BusinessInfo.sox?__folder=/ovalreport&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}
	else if((v_year1!=null || v_year1!="") && (v_year2==null ||v_year2=="")){
		window.open("<%= reportURL %>/servlet/ExcecuteReport/BusinessInfo.sox?__folder=/ovalreport&startdate="+startdate+"&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}
	else if((v_year1==null || v_year1=="") && (v_year2!=null ||v_year2!="")){
		window.open("<%= reportURL %>/servlet/ExcecuteReport/BusinessInfo.sox?__folder=/ovalreport&enddate="+enddate+"&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}else{
		window.open("<%= reportURL %>/servlet/ExcecuteReport/BusinessInfo.sox?__folder=/ovalreport&startdate="+startdate+"&enddate="+enddate+"&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}
}
function page_csv(){
	v_year1=document.cform.years1.value;
	v_year2=document.cform.years2.value;
	v_month1=document.cform.months1.value;
	v_month2=document.cform.months2.value;
	str1="TO_DATE(b.YEAR || '-' || b.MONTH,'yyyy-mm')>=TO_DATE(";
	str2=v_year1;
	str3="|| '-' ||";
	str4=v_month1;
	str5=" ,'yyyy-mm')";
	startdate=str1+str2+str3+str4+str5;
	
	str_1="TO_DATE(b.YEAR || '-' || b.MONTH,'yyyy-mm')<=TO_DATE(";
	str_2=v_year2;
	str_3="|| '-' ||";
	str_4=v_month2;
	str_5=" ,'yyyy-mm')";
	enddate=str_1+str_2+str_3+str_4+str_5;
	
	
	var objdeptcode=eval("cform.regionid");
  	var ss=objdeptcode.selectedIndex;
  	AREA1NAME=objdeptcode.options[ss].text;
  	if(AREA1NAME=="ALL"){
  		AREA1NAME="";
  	}
  	
  	var objdeptcode1=eval("cform.proviceofficelist");
  	var ss1=objdeptcode1.selectedIndex;
  	AREA2NAME=objdeptcode1.options[ss1].text;
  	if(AREA2NAME=="----------" || AREA2NAME=="-------"){
  		AREA2NAME="";
  	}
  	
  	var objdeptcode2=eval("cform.businessarealist");
  	var ss2=objdeptcode2.selectedIndex;
  	AREA3NAME=objdeptcode2.options[ss2].text;
  	if(AREA3NAME=="----------" || AREA3NAME=="-------"){
  		AREA3NAME="";
  	}
	SALESREPNAME=document.cform.employeename.value;
	if((v_year1==null || v_year1=="") && (v_year2==null || v_year2=="")){
		window.open("<%= reportURL %>/csv?__report=/ovalreport/BusinessInfo.txt&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}
	else if((v_year1!=null || v_year1!="") && (v_year2==null ||v_year2=="")){
		window.open("<%= reportURL %>/csv?__report=/ovalreport/BusinessInfo.txt&startdate="+startdate+"&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}
	else if((v_year1==null || v_year1=="") && (v_year2!=null ||v_year2!="")){
		window.open("<%= reportURL %>/csv?__report=/ovalreport/BusinessInfo.txt&enddate="+enddate+"&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}else{
		window.open("<%= reportURL %>/csv?__report=/ovalreport/BusinessInfo.txt&startdate="+startdate+"&enddate="+enddate+"&AREA1NAME="+escape(encodeURI(AREA1NAME))+"&AREA2NAME="+escape(encodeURI(AREA2NAME))+"&AREA3NAME="+escape(encodeURI(AREA3NAME))+"&SALESREPNAME="+escape(encodeURI(SALESREPNAME)));
	}
}

</script>

<style type="text/css">
*{padding:0;margin:0;}
.container {width:230px;margin:1px auto;}
.holder2 {color:#FDFAC5;}
/*wu tu yuan jiao*/
.b1 {height:1px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; margin:0 5px;background-color:#FDFAC5}
.b2 {height:1px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; border-right:2px solid #FDFAC5; border-left:2px solid #FDFAC5; margin:0 3px;background-color:#FDFAC5}
.b3 {height:1px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; border-right:1px solid #FDFAC5; border-left:1px solid #FDFAC5; margin:0 2px;background-color:#FDFAC5}
.b4 {height:2px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; border-right:1px solid #FDFAC5; border-left:1px solid #FDFAC5; margin:0 1px;background-color:#FDFAC5}
.content {border-right:1px solid #FDFAC5; height:15px;border-left:1px solid #FDFAC5;background-color:#FDFAC5}
</style>

</head>

<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_zylbusinessareainfobuystock"/>
    <input type="hidden" name="actionname"/>
    <input type="hidden" name="categorycode"/>
    <input type="hidden" name="mark" value="1"/>
<custom:hidden property="userid" name="userinfo" scope="session"></custom:hidden>
<custom:hidden property="deptcode" name="userinfo" scope="session"></custom:hidden>
<%--  page location   --%>
    <%@ include file="/inc/PageLocation.inc" %>
<custom:hidden property="globalpccode"></custom:hidden>
    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
<%--  search criteria  --%>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0">
           <tr>
          <td class="summary_top" width="10%" colspan="3"></td>
          </tr>

          </table>
        </td>
      </tr>
      	<tr>
        <td>
  <table width="100%" border="0" cellspacing="0" >
  <tr>
 
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
	        	<td nowrap="nowrap">
	        		<custom:selectdic property="years1" dictType="Years" defaultValue="----" defaultValueCost="" command="notnull" label="L_Year1"/>
	        		<custom:selectdic property="months1" dictType="Months" defaultValue="----" defaultValueCost="" command="notnull" label="L_Month"/>&nbsp;-&nbsp;
	        		<custom:selectdic property="years2" dictType="Years" defaultValue="----" defaultValueCost="" command="notnull" label="L_Year1"/>
	        		<custom:selectdic property="months2" dictType="Months" defaultValue="----" defaultValueCost="" command="notnull" label="L_Month"/>
	        	</td>
	        	
	        	
	        	
                    </tr>
        	     <% 
	                if(new Integer(1).equals(issalesman)){
	             %> 
	                <%}else{ %>
        	    <tr>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_Businessarea") +  label.getLabelName("L_Colon") %></td>
        	  	<td style="width:160px;" class="td_left"><custom:select property="regionid" optionInnerTextKey="regionname" style="width:160px" optionsName="resultregion" optionValueKey="regionid" onchange="page_getpriviceoffice()" defaultValue="ALL" defaultValueCost=""/></td>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_Department") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;" class="td_left">
					<custom:select property="proviceofficelist" optionInnerTextKey="proviceofficename" optionsName="resultproviceoffice" optionValueKey="proviceofficecode" defaultValue="----------" style="width:150px" defaultValueCost="" onchange="page_getbusinessarea();"/>
		        </td>
			    <td style="width:70px;" class="td_right"><%=label.getLabelName("L_BusinessAreaName") +  label.getLabelName("L_Colon") %></td>
				<td style="width:180px;" class="td_left">
				<custom:select property="businessarealist" optionInnerTextKey="businessareaname" optionsName="resultbusinessarea" optionValueKey="businessareacode" defaultValue="----------" style="width:180px" defaultValueCost=""/> </td>
        	     <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessContact") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;">
			<custom:text property="employeename" size="20" readonly="true" style="border:1px #7F9DB9 solid;"/>
			<a onClick="javascript:popRep();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> 
			<custom:hidden property="userids"/>
			<custom:hidden property="employeecode"/>
		   </td>
				<!--<td><a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
			---->
			<%} %>
        	</tr>
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="2">
        <div style="width:100%;height=20;overflow=auto;">
          <table width="180%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
			<tr class="deepblue-left">
				<td width="22">&nbsp;</td>
				
			</tr>

          </table>
		  </div>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
              	<a onclick="page_excel();"><custom:button type="1" label="L_ExcelE" imgsrc="Modify.gif" border="0" style="width:100" privilegeCode="MB-PYDC01"/></a>&nbsp;&nbsp;
				<a onclick="page_csv();"><custom:button type="1" label="L_ExportCSV" imgsrc="Modify.gif" border="0" style="width:100" privilegeCode="MB-PYDC02"/></a>&nbsp;&nbsp;	
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</body>
<script>
onLoad();
changecategorycode();
</script>
</html>

